home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 2002 November / SGI Freeware 2002 November - Disc 1.iso / dist / fw_apache2.idb / usr / freeware / apache2 / include / apr_user.h.z / apr_user.h
C/C++ Source or Header  |  2002-07-08  |  7KB  |  195 lines

  1. /* ====================================================================
  2.  * The Apache Software License, Version 1.1
  3.  *
  4.  * Copyright (c) 2000-2002 The Apache Software Foundation.  All rights
  5.  * reserved.
  6.  *
  7.  * Redistribution and use in source and binary forms, with or without
  8.  * modification, are permitted provided that the following conditions
  9.  * are met:
  10.  *
  11.  * 1. Redistributions of source code must retain the above copyright
  12.  *    notice, this list of conditions and the following disclaimer.
  13.  *
  14.  * 2. Redistributions in binary form must reproduce the above copyright
  15.  *    notice, this list of conditions and the following disclaimer in
  16.  *    the documentation and/or other materials provided with the
  17.  *    distribution.
  18.  *
  19.  * 3. The end-user documentation included with the redistribution,
  20.  *    if any, must include the following acknowledgment:
  21.  *       "This product includes software developed by the
  22.  *        Apache Software Foundation (http://www.apache.org/)."
  23.  *    Alternately, this acknowledgment may appear in the software itself,
  24.  *    if and wherever such third-party acknowledgments normally appear.
  25.  *
  26.  * 4. The names "Apache" and "Apache Software Foundation" must
  27.  *    not be used to endorse or promote products derived from this
  28.  *    software without prior written permission. For written
  29.  *    permission, please contact apache@apache.org.
  30.  *
  31.  * 5. Products derived from this software may not be called "Apache",
  32.  *    nor may "Apache" appear in their name, without prior written
  33.  *    permission of the Apache Software Foundation.
  34.  *
  35.  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  36.  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  37.  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  38.  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  39.  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  40.  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  41.  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  42.  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  43.  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  44.  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  45.  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  46.  * SUCH DAMAGE.
  47.  * ====================================================================
  48.  *
  49.  * This software consists of voluntary contributions made by many
  50.  * individuals on behalf of the Apache Software Foundation.  For more
  51.  * information on the Apache Software Foundation, please see
  52.  * <http://www.apache.org/>.
  53.  */
  54.  
  55. #ifndef APR_USER_H
  56. #define APR_USER_H
  57.  
  58. #include "apr.h"
  59. #include "apr_errno.h"
  60. #include "apr_pools.h"
  61.  
  62. #ifdef __cplusplus
  63. extern "C" {
  64. #endif /* __cplusplus */
  65.  
  66. /**
  67.  * @file apr_user.h
  68.  * @brief APR User ID Services 
  69.  */
  70. /**
  71.  * @defgroup APR_User User id services
  72.  * @ingroup APR
  73.  * @{
  74.  */
  75.  
  76. /**
  77.  * Structure for determining user ownership.
  78.  */
  79. #ifdef WIN32
  80. typedef PSID                      apr_uid_t;
  81. #else
  82. typedef uid_t                     apr_uid_t;
  83. #endif
  84.  
  85. /**
  86.  * Structure for determining group ownership.
  87.  */
  88. #ifdef WIN32
  89. typedef PSID                      apr_gid_t;
  90. #else
  91. typedef gid_t                     apr_gid_t;
  92. #endif
  93.  
  94. #if APR_HAS_USER 
  95.  
  96. /**
  97.  * Get the userid (and groupid) of the calling process
  98.  * @param userid   Returns the user id
  99.  * @param groupid  Returns the user's group id
  100.  * @param p The pool from which to allocate working space
  101.  * @remark This function is available only if APR_HAS_USER is defined.
  102.  */
  103. APR_DECLARE(apr_status_t) apr_current_userid(apr_uid_t *userid,
  104.                                              apr_gid_t *groupid,
  105.                                              apr_pool_t *p);
  106.  
  107. /**
  108.  * Get the user name for a specified userid
  109.  * @param username Pointer to new string containing user name (on output)
  110.  * @param userid The userid
  111.  * @param p The pool from which to allocate the string
  112.  * @remark This function is available only if APR_HAS_USER is defined.
  113.  */
  114. APR_DECLARE(apr_status_t) apr_get_username(char **username, apr_uid_t userid, apr_pool_t *p);
  115.  
  116. /**
  117.  * Get the userid (and groupid) for the specified username
  118.  * @param userid   Returns the user id
  119.  * @param groupid  Returns the user's group id
  120.  * @param username The username to lookup
  121.  * @param p The pool from which to allocate working space
  122.  * @remark This function is available only if APR_HAS_USER is defined.
  123.  */
  124. APR_DECLARE(apr_status_t) apr_get_userid(apr_uid_t *userid, apr_gid_t *groupid,
  125.                                          const char *username, apr_pool_t *p);
  126.  
  127. /**
  128.  * Get the home directory for the named user
  129.  * @param dirname Pointer to new string containing directory name (on output)
  130.  * @param username The named user
  131.  * @param p The pool from which to allocate the string
  132.  * @remark This function is available only if APR_HAS_USER is defined.
  133.  */
  134. APR_DECLARE(apr_status_t) apr_get_home_directory(char **dirname, const char *username, apr_pool_t *p);
  135.  
  136. /**
  137.  * Compare two user identifiers for equality.
  138.  * @param left One uid to test
  139.  * @param right Another uid to test
  140.  * @return APR_SUCCESS if the apr_uid_t strutures identify the same user,
  141.  * APR_EMISMATCH if not, APR_BADARG if an apr_uid_t is invalid.
  142.  * @remark This function is available only if APR_HAS_USER is defined.
  143.  */
  144. #if defined(WIN32)
  145. APR_DECLARE(apr_status_t) apr_compare_users(apr_uid_t left, apr_uid_t right);
  146. #else
  147. #define apr_compare_users(left,right) (((left) == (right)) ? APR_SUCCESS : APR_EMISMATCH)
  148. #endif
  149.  
  150. /**
  151.  * Get the group name for a specified groupid
  152.  * @param groupname Pointer to new string containing group name (on output)
  153.  * @param groupid The groupid
  154.  * @param p The pool from which to allocate the string
  155.  * @remark This function is available only if APR_HAS_USER is defined.
  156.  */
  157. APR_DECLARE(apr_status_t) apr_group_name_get(char **groupname, 
  158.                                              apr_gid_t groupid, apr_pool_t *p);
  159.  
  160. /** @deprecated @see apr_group_name_get */
  161. APR_DECLARE(apr_status_t) apr_get_groupname(char **groupname, 
  162.                                             apr_gid_t groupid, apr_pool_t *p);
  163.  
  164. /**
  165.  * Get the groupid for a specified group name
  166.  * @param groupid Pointer to the group id (on output)
  167.  * @param groupname The group name to look up
  168.  * @param p The pool from which to allocate the string
  169.  * @remark This function is available only if APR_HAS_USER is defined.
  170.  */
  171. APR_DECLARE(apr_status_t) apr_get_groupid(apr_gid_t *groupid, const char *groupname, apr_pool_t *p);
  172.  
  173. /**
  174.  * Compare two group identifiers for equality.
  175.  * @param left One gid to test
  176.  * @param right Another gid to test
  177.  * @return APR_SUCCESS if the apr_gid_t strutures identify the same group,
  178.  * APR_EMISMATCH if not, APR_BADARG if an apr_gid_t is invalid.
  179.  * @remark This function is available only if APR_HAS_USER is defined.
  180.  */
  181. #if defined(WIN32)
  182. APR_DECLARE(apr_status_t) apr_compare_groups(apr_gid_t left, apr_gid_t right);
  183. #else
  184. #define apr_compare_groups(left,right) (((left) == (right)) ? APR_SUCCESS : APR_EMISMATCH)
  185. #endif
  186.  
  187. #endif  /* ! APR_HAS_USER */
  188.  
  189. /** @} */
  190. #ifdef __cplusplus
  191. }
  192. #endif
  193.  
  194. #endif  /* ! APR_USER_H */
  195.